//
// Created by lenovo on 2024/2/9.
//

#ifndef PHYSICS_ENGINE_POSITION2D_H
#define PHYSICS_ENGINE_POSITION2D_H

class Position2D {
public:
    double x {0};
    double y {0};

    //实现(x,y)构造函数与默认构造函数
    Position2D(double x, double y) :  x(x), y(y) {}
    Position2D() = default;

    //实现getter与setter
    double getX() const {
        return x;
    }

    void setX(double x) {
        this->x = x;
    }

    double getY() const {
        return y;
    }

    void setY(double y) {
        this->y = y;
    }

    //重载+-运算符
    Position2D operator+(const Position2D& rhs) const {
        return {x + rhs.x, y + rhs.y};
    }

    Position2D operator-(const Position2D& rhs) const {
        return {x - rhs.x, y - rhs.y};
    }

    Position2D operator* (double n) const {
        return {n * this->getX() , n * this->getY()} ;
    }

//    Position2D operator*(double rhs) const {
//        return {x * rhs, y * rhs};
//    }

//    Position2D operator/(double rhs) const {
//        return {x / rhs, y / rhs};
//    }
};


#endif //PHYSICS_ENGINE_POSITION2D_H
